<?php 
	session_start();
	if(!isset($_SESSION['username']))
		header("location:../index.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

 <link rel="stylesheet" href="../admin_css/product.css" type="text/css" />
 <?php 
include '../../inc/reuse/dbconfig.php';
$products_id = "";
$products_name="";
$products_description = "";
$head_topic = "เพิ่มสินค้า";

if(isset($_GET['products_id']))
{
	$products_id = $_GET['products_id'];	
	$sql = "SELECT * FROM products WHERE products_id = $products_id";
	$rsd = mysql_query($sql);
	$row = mysql_fetch_array($rsd);
	$head_topic = "แก้ไขสินค้า";
	$products_name = $row['products_name'];
	$products_description = $row['products_description'];
}
?>
<title>Admin | <?=$head_topic?></title>
</head>

<script type="text/javascript" src="../js/page_function/products.js"></script>
<body>
	<div class="button_topic" style="padding-left: 25px;"><?=$head_topic?></div>
		
  		<table border="0" class="tb1" style="font-family: sans-serif; font-size: 12px;">
  			<tr valign="top">
				<td>สินค้าหลัก</td>
	  			<td><select id="products_main" onChange="dia_products_cmbMain(<?=$products_id?>)" style="width: 355px"> 
  						<?php include("../command/rawdata/getMainCategoryForDropdown.php");?> 	
					</select> <span style="color:red;">*</span>
				</td>
			</tr>
			<tr valign="top">
				<td>สินค้าย่อย</td>
				<td><select id="products_sub" style="width: 355px">
  						<?php include("../command/rawdata/getSubCategoryForDropdown.php");?> 	
					</select> <span style="color:red;">*</span>
				</td>
			</tr>
			<tr valign="top">
				<td>ชื่อสินค้า</td> 
				<td><input type="text" id="dia_products_name" name="dia_products_name" value= "<?=$products_name?>"  style="width: 350px"/> <span style="color:red;">*</span></td>
	</tr>
	<tr valign="top">
	<td>รายละเอียดสินค้า  </td>
	<td><textarea  id="dia_products_description" name="dia_products_description" style="width: 350px;height: 100px;"><?=$products_description?></textarea> <span style="color:red;">*</span></td>
	</tr>
	<tr valign="top">
	<td><input type="submit" value="เพิ่มรูปสินค้า &raquo;"onClick="dia_products_addProducts(<?=$products_id?>)"></input></td>
	<td>&nbsp;</td>
	</tr>
<form id="formSubmit" action="../command/rawdata/updateProducts.php" method="post">
	<input type="hidden" id="dia_productsId" name="dia_productsId"/>
	<input type="hidden" id="dia_mainCategory" name="dia_mainCategory"/>
	<input type="hidden" id="dia_subCategory" name="dia_subCategory"/>
	<input type="hidden" id="dia_productsName" name="dia_productsName"/>	
	<input type="hidden" id="dia_description" name="dia_description"/>
</form>
</table>
</body>
</html>

